package org.rich.charlesmurphy.model;

import java.util.HashSet;
import java.util.Set;

/**
 * HTTP status codes that we care about.
 * @author Rich
 */
public enum StatusCode {

	SUCCSSS("200"),
	CACHED("304"),
	NOT_FOUND("404"),
	UNKNOWN;
	
	private Set<String> codes;
	
	StatusCode(String ... extensions) {
		this.codes = new HashSet<String>();
		for (String e : extensions) {
			this.codes.add(e);
		}
	}
	
	public static StatusCode fromCode(String code) {
		for (StatusCode sc : StatusCode.values()) {
			if (sc.codes.contains(code.trim())) {
				return sc;
			}
		}
		return UNKNOWN;
	}

}
